package com.tangly.module.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tangly.module.entity.CmsArticleEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * created by yehao on 2018/7/26.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(description = "资讯实体")
public class AppCmsArticleVO {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    private Integer id;

    @NotNull
    @ApiModelProperty(value ="创建时间，,example = \"2018-06-13 08:00:00\"" )
    private Date create_time;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value ="更新时间，,example = \"2018-06-13 08:00:00\"" )
    private Date update_time;

    @NotNull
    @ApiModelProperty(value = "是否删除")
    private Boolean is_delete;


    @ApiModelProperty(value = "类型")
    private String type;

    @NotNull
    @ApiModelProperty(value = "是否发布")
    private Boolean status;


    @ApiModelProperty(value = "文章摘要")
    private String summary;

    @ApiModelProperty(value = "文章首页显示图片")
    private String picture;

    @ApiModelProperty(value = "文章文本内容")
    private String content;

    @ApiModelProperty(value = "文章内容-排版格式")
    private String content_html;

    @NotNull
    @ApiModelProperty(value = "用户信息表id 外键")
    private Integer user_info_id;

    public static AppCmsArticleVO convert(CmsArticleEntity cmsArticleEntity){
        AppCmsArticleVO vo=new AppCmsArticleVO();
        BeanUtils.copyProperties(cmsArticleEntity,vo);
        return  vo;
    }
}
